package io.babystar.modules.business.service.impl;

import io.babystar.common.utils.PageUtils;
import io.babystar.common.utils.Query;
import io.babystar.modules.business.dao.BaseChannelDao;
import io.babystar.modules.business.entity.BaseChannelEntity;
import io.babystar.modules.business.service.BaseChannelService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


@Service("baseChannelService")
public class BaseChannelServiceImpl extends ServiceImpl<BaseChannelDao, BaseChannelEntity> implements BaseChannelService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String businessId = (String) params.get("businessId");
        String channel = (String) params.get("key");
        IPage<BaseChannelEntity> page = this.page(
                new Query<BaseChannelEntity>().getPage(params),
                new QueryWrapper<BaseChannelEntity>()
                        .eq(StringUtils.isNotBlank(businessId),"business_id",businessId)
                        .eq(StringUtils.isNotBlank(channel),"channel",channel)
        );

        return new PageUtils(page);
    }

}